<!--
公告中心增加
 add by yyp 2019-05-13
-->
<template lang="pug">
  kalix-dialog.user-add(bizKey="NoticeCenter" ref="kalixBizDialog"
  v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL")
    div.el-form(slot="dialogFormSlot" style=" width:60%;margin:auto;")
      el-form-item(label="公告标题" prop="noticeTitle" label-width="120px" v-bind:rules="rules.noticeTitle")
        el-input(v-model="formModel.noticeTitle" style="width:80%")
      el-form-item.short(label="公告类别" prop="noticeType" label-width="120px" v-bind:rules="rules.noticeType" )
        kalix-select(v-model="formModel.noticeType"  v-bind:requestUrl="requestUrl" id="name" appName="categoryname" placeholder="请选择公告类别" style="width:80%")
        <!--el-select(v-model="formModel.noticeType" v-bind:requestUrl="requestUrl" id="name" appName="categoryname" placeholder="请选择公告类别" style="width:80%" @change="obtainValue" )-->
          <!--el-option(v-for="item in options" v-bind:requestUrl="requestUrl" :key="item.name" id="name" )-->
      el-form-item(label="公告日期" prop="noticeDate" label-width="120px" v-bind:rules="rules.noticeDate")
        kalix-date-picker(v-model="formModel.noticeDate" style="width:80%" type="date")
      el-form-item(label="公告详情" prop="noticeDetails" label-width="120px" v-bind:rules="rules.noticeDetails")
        el-input(v-model="formModel.noticeDetails" style="width:80%"  type="textarea")
</template>

<script type="text/ecmascript-6">
  import FormModel from './model'
  import {NoticeCenterURL, CategoryNameURL} from '../../config.toml'
  import KalixClansmanUpload from '../../../../../components/fileUpload/upload'
  import {baseURL} from '../../../../../config/global.toml'
  import KalixSelect from '../../../../../components/corelib/components/common/baseSelect'
  export default {
    name: 'noticecenterAdd',
    components: {KalixSelect, KalixClansmanUpload},
    data() {
      return {
        formModel: Object.assign({}, FormModel),
        action: baseURL + '/camel/rest/upload',
        rules: {
          name: [{required: true, message: '请输入名称', trigger: 'blur'}]
        },
        requestUrl: CategoryNameURL,
        targetURL: NoticeCenterURL,
        options: [],
        labelWidth: '110px'
      }
    },
    mounted() {
    },
    methods: {
      // initOptions() {
      //   const DictKey = `${this.appName.toUpperCase()}-KEY`
      //   if (!Cache.get(DictKey)) {
      //     this.$http
      //       .get(this.requestUrl, {
      //         // params: {page: 1, start: 0, limit: 20}
      //         params: this.paramObj
      //       })
      //       .then(res => {
      //         console.log('res==============', res.data)
      //         this.options = res.data
      //         if (res.data.totalCount === 0) {
      //           Message.warning(this.warnMsg)
      //         }
      //         if (res.data.data) {
      //           this.options = res.data.data
      //           this.defaultSelectVal()
      //         }
      //         Cache.save(DictKey, JSON.stringify(this.options))
      //       })
      //   } else {
      //     this.options = JSON.parse(Cache.get(DictKey))
      //     this.defaultSelectVal()
      //   }
      // },
      // change(value) {
      //   console.log('value............', value)
      //   this.$emit('input', value)
      //   let item = this.options.find(e => {
      //     return e.id === value
      //   })
      //   this.$emit('selectChange', item)
      // },
      // defaultSelectVal() {
      //   if (this.defaultSelect) {
      //     this.options.forEach((item) => {
      //       if (this.defaultSelectLabel === item[this.label]) {
      //         this.currentValue = item[this.id]
      //         this.$emit('vauleSetForm', this.currentValue)
      //       }
      //     })
      //   }
      // },
      obtainValue(value) {
        console.log(value)
      },
      getFilePath(filePath, fileName) {
        console.log('--getFilePath---', filePath)
        console.log('--fileName---', fileName)

        this.formModel.newUrl = filePath
        this.formModel.imgName = fileName
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus">
  .el-form
    width 70%
    margin auto
    .el-input
      width 70%
    .radio
      margin-left 20px
      .el-radio
        color: #3465cb
        font-weight: bold
        font-size: 14px
</style>
